#ifndef BASE64_H
#define BASE64_H

#include <stdint.h>
/**
 *  
 * @author Tang (2018/12/29) 
 *  
 * @param[in] _len_ data length before encoding 
 *  
 * @return Encoding length through base64 
 */
#define BASE64_ENCODE_LEN(_len_) ((((_len_) + 2) / 3) << 2)
/**
 *  
 * @author Tang (2018/12/29) 
 *  
 * @param[in] _len_ data length before decoding 
 *  
 * @return Decoding length through base64 
 *  
 * @note  BASE64_DECODE_LEN(bytes.len) >=  base64_decode(bytes)
 */
#define BASE64_DECODE_LEN(_len_) (((_len_) >> 2) * 3)
/**
 * @brief Encode data by base64
 * 
 * @author Tang (2018/12/29)
 * 
 * @param[in] psrc Pointer to the source data
 * @param[in] src_len Length of the source data
 * @param[out] pdst Pointer to the destination data 
 * @param[in] dst_len Length of the destination data
 * 
 * @return uint32_t Error(0)/Others(data length after encoding)
 */
extern uint32_t base64_encode(uint8_t *psrc, uint32_t src_len, uint8_t *pdst, uint32_t dst_len);
/**
 * @brief Decode and check data by base64
 * 
 * @author Tang (2018/12/29)
 * 
 * @param[in] psrc Pointer to the source data
 * @param[in] src_len Length of the source data
 * @param[out] pdst Pointer to the destination data 
 * @param[in] dst_len Length of the destination data
 * 
 * @return uint32_t Error(0)/Others(data length after decoding)
 */
extern uint32_t base64_decode(uint8_t *psrc, uint32_t src_len, uint8_t *pdst, uint32_t dst_len);

#endif
